<template>
  <div class="w">
    <!-- 面包屑 -->
    <div class="title">
      <a href="#">首页</a> > <a href="#">购物车</a> > <a href="#">支付订单</a>
    </div>
    <!-- 支付成功 -->
    <div class="orderSuccess">
      <div class="orderSuccess-left">
        <span class="iconfont icon-success-filling"></span>
        <div class="content">
          <p>订单提交成功!请尽快完成支付</p>
          <p>支付还剩{{ min }}分{{ sec }}秒,超时后将取消订单</p>
        </div>
      </div>
      <div class="orderSuccess-right">
        应付总额：<span class="payMoney">￥97</span>
      </div>
    </div>

    <div class="pay">
      <h5>选择以下支付方式付款</h5>
      <h4>支付平台</h4>
      <div class="payPlatform">
        <button></button>
        <!-- 支付宝 -->
        <button @click="toAlipay">
          <a :href="payUrl" target="_blank" class="alipay"></a>
        </button>
      </div>
      <h4>支付方式</h4>
      <div class="payWay">
        <button>招商银行</button>
        <button>工商银行</button>
        <button>建设银行</button>
        <button>农业银行</button>
        <button>交通银行</button>
      </div>
    </div>
  </div>

  <el-dialog
    v-model="Visible"
    title="正在支付..."
    :before-close="handleClose"
    class="dialog"
    width="1"
  >
    <div class="payNow">
      <div class="left">
        <img src="./images/pay.gif" alt="" />
      </div>
      <div class="right">
        <p>如果支付成功<a href="#">查看订单详情</a></p>
        <p>如果支付失败<a href="/">查看相关疑问</a></p>
      </div>
    </div>
  </el-dialog>
</template>

<script>
import { toPay } from '@/api/pay'
export default {
  name: 'xPay',
  data() {
    return {
      Visible: false,
    }
  },
  methods: {
    toAlipay() {
      this.Visible = true
    },
  },
  computed: {
    payUrl() {
      const redirect = encodeURIComponent(
        'http://localhost:8080/#/pay/callback'
      )
      // const payUrl = `${baseURL}pay/aliPay?orderId=${route.query.orderId}&redirect=${redirect}`

      const id = this.$route.query.orderId
      return `https://apipc-xiaotuxian-front.itheima.net/pay/aliPay?orderId=${id}&redirect=${redirect}`
    },
  },
}
</script>

<style scoped>
* {
  margin: 0;
  padding: 0;
}

ul li {
  list-style: none;
}

body {
  background-color: #f5f5f5;
}

.w {
  width: 1240px;
  margin: 0 auto;
}

/* 面包屑 */
.title {
  height: 72px;
  line-height: 72px;
}

.title a {
  text-decoration: none;
  font-size: 14px;
  color: #666;
}

.payContainer {
  padding: 0 20px;
  background-color: #fff;
}

/* 支付成功 */
.orderSuccess {
  display: flex;

  align-items: center;
  height: 240px;
  padding: 0 80px;
  background-color: #fff;
}

.orderSuccess p {
  color: #999;
  font-size: 16px;
}

.orderSuccess p:nth-child(1) {
  color: #333;
  font-size: 20px;
}

.orderSuccess-left {
  display: flex;
  flex: 7;
  /* height: 100%; */
  margin-left: 30px;
}

.orderSuccess-right {
  flex: 1;
  color: #999;
  font-size: 16px;
}

.payMoney {
  color: #cf4444;
  font-size: 20px;
}

/* 支付方式 */
.pay {
  margin-top: 20px;
  height: 385px;
  padding-bottom: 80px;
  background-color: #fff;
}

h5,
h4 {
  height: 70px;
  line-height: 70px;
  font-weight: normal;
  padding-left: 30px;
}

h5 {
  border-bottom: 1px solid rgb(245, 245, 245);
}

button {
  width: 150px;
  height: 50px;
  margin-left: 30px;
  color: #666;
  border: 1px solid rgb(228, 228, 228);
  background-color: transparent;
}
button:hover {
  border: 1px solid rgb(39, 186, 155);
}

.payPlatform button:nth-child(1) {
  background: url(./images/weixin.jpg) no-repeat;
  background-size: 150px;
  background-position: 0 0;
}
.payPlatform button:nth-child(2) {
  background: url(./images/zhifubao.png) no-repeat;
  background-size: 150px;
  background-position: 0 0;
}
.el-icon-share {
  width: 20px;
  height: 20px;
  size: 20px;
}
/* 图标 */
.iconfont {
  display: inline-block;
  font-size: 80px;
  color: #1dc779;
}
.content {
  margin-top: 15px;
  margin-left: 10px;
}
.alipay {
  display: inline-block;
  width: 100%;
  height: 100%;
}
/* dialog */
.payNow {
  display: flex;
  justify-content: space-between;
}
.payNow .left img {
  margin-left: 100px;
  margin-top: 10px;
  width: 250px;
}
.payNow .right p {
  font-size: 14px;
  color: #333;
  margin: 60px 140px;
}
.payNow .right p a {
  display: block;
  text-decoration: none;
  font-size: 16px;
  color: #27ba98;
}
</style>